<template>
	<view>
		<view class="sticky-box">
			<search-input ref="searchInput"
				@searchConfirm="handleSearch($event)"></search-input>
		</view>
		<view class="bill-list">
			<view class="bill-item"
				@tap="toGoodsList(item)"
				v-for="(item, index) in billList" :key="index">
				<view class="flex-row bill-header">
					<view class="bill-no">
						NO.{{item.Code}}
					</view>
					<view class="bill-status yellow-text">
						未扫
					</view>
				</view>
				<view class="flex-col bill-content">
					<view class="flex-row bill-row">
						<view class="title">
							品种数：
						</view>
						<view class="value">
							{{item.GoodsAmount}}
						</view>
					</view>
					<view class="flex-row bill-row">
						<view class="title">
							配送企业：
						</view>
						<view class="value">
							{{item.SupplierName}}
						</view>
					</view>
					<view class="flex-row bill-row">
						<view class="title">
							日期：
						</view>
						<view class="value">
							{{item.StockoutTime}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex'
	import searchInput from '@/components/search-input/search-input.vue';
	var that;
	export default {
		components: { searchInput },
		data() {
			return {
				searchVal: '',
				billList: []
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.userInfo, // userInfo
				Token: state => state.Token, // Token
			})  
		},
		onLoad() {
			that = this
		},
		onShow() {
			that.getServerData()
		},
		methods: {
			getServerData() {
				that.getBillList()
			},
			getBillList() {
				const Filter = `${that.searchVal}`;
				let requestData = {}
				
				that.$request.globalRequest('supplierstock/supplierlist', 'POST', requestData, '', 0).then(res => {
					console.log(res);
					let data = res;
					if(data.length !== 0) {
						that.billList = data;
					} else {
						that.billList = []
					}
				}).catch( res => {
					that.$common.showNormalToast(res);
					console.log(res);
				})
			},
			handleSearch(res) {
				that.searchVal = res.value
			},
			toGoodsList(item) {
				const url = {
					path: '/pagesStockIn/goodsList/goodsList', 
					query: { 
						title: item.Name,
						type: '',
						Id: item.Id,
						Code: item.Code
					}
				}
				that.$Router.push(url)
			},
		}
	}
</script>

<style lang="scss" scoped>
@import "deliveryList.scss";
</style>
